import {
  mapGetters
} from 'vuex'
export default {
  computed: {
    ...mapGetters('m_cart', ['total']),
  },
  onShow() {
    this.setBadge()
  },
  watch: {
    total() {
      // 监听总数的变化
      this.setBadge()
    }
  },
  methods: {
    // 设置购物车右上角数字图标数值
    setBadge() {
      uni.setTabBarBadge({
        index: 2,
        text: String(this.total)
      })
    }
  }
}
